﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sdg.Domain.BizObj
{
    public class Connection : IBizObj
    {
        private SqlConnectionStringBuilder bldr = new SqlConnectionStringBuilder();

        public string ServerName { get; set; }
        public string DbName { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public bool IntegratedSecurity { get; set; }

        public string ConnectionString
        {
            get
            {
                bldr.ApplicationName = "SDataGen";
                bldr.DataSource = ServerName;
                bldr.IntegratedSecurity = IntegratedSecurity;

                bldr.UserID = IntegratedSecurity ? "" : UserName;
                bldr.Password = IntegratedSecurity ? "" : Password;


                bldr.WorkstationID = Environment.MachineName;
                bldr.InitialCatalog = DbName;

                return bldr.ConnectionString;
            }

        }

    }
}
